#! /bin/sh

#可执行文件名称
jarname=cloudSoftlicense-api
mainCls=com.sense.cloud.softlicense.server.App
jvmopts="-Xms512m -Xmx512m"
apphome=`pwd`
logdir=$apphome/logs
logfile=$apphome/logs/log.log

#if
if [ -d $logdir ];then
  echo ""
else
  mkdir $logdir
fi

if [ -d $logfile ];then
  echo ""
else
  touch $logfile
fi

chmod +x *

jarfile=$jarname.jar
classpath=./conf:./lib/*:$jarfile

#开始启动
start(){
    echo "app is start running ..."
    exec java $jvmopts -cp $classpath $mainCls 5 > logs/log.log & 
}

#停止运行
stop(){
    ps -ef|grep $jarname|awk '{print $2}'|while read pid
    do
        kill -9 $pid
    done
	echo "app is stop"
}

#执行配置
case "$1" in
start)
  start
  ;;
stop)
  stop
  ;;
restart)
  stop
  start
  ;;
*)
  printf 'Use cmd as: %s {start|stop|restart}\n' "$prog"
  exit 1
  ;;
esac
